// src/user/user.module.ts
import { Module } from '@nestjs/common';
import { MongooseModule, getConnectionToken } from '@nestjs/mongoose';
import { Connection } from 'mongoose';
import { Work, WorkSchema } from './schemas/work.schema';
import { WorkService } from './work.service';
import { WorkController, ChannelController } from './work.controller';
import { CustomLoggerProvider } from '../common/provider/logger.provider';
import { AuthModule } from '@/auth/auth.module';
import { HttpModule } from '@nestjs/axios';
import { CaslModule } from '@/casl/casl.module';

@Module({
  imports: [
    MongooseModule.forFeatureAsync([
      {
        name: Work.name,
        // eslint-disable-next-line @typescript-eslint/no-unused-vars
        useFactory: (connection: Connection) => {
          return WorkSchema;
        },
        inject: [getConnectionToken()],
      },
    ]),
    AuthModule,
    CaslModule,
    HttpModule,
  ],
  providers: [WorkService, CustomLoggerProvider],
  controllers: [WorkController, ChannelController],
  exports: [WorkService],
})
export class WorkModule {}
